package lv.solcraft.replication.client.http;

import org.apache.log4j.Logger;
import org.restlet.Client;

public class ServerPing {

    private static final Logger log = Logger.getLogger(ServerPing.class);
    private final String serverUrl;

    private ServerPing(String serverUrl) {
        this.serverUrl = serverUrl;
    }

    public boolean ping() {
        try {
            Client client = HttpClientFactory.get();
            client.get(serverUrl + "/");
            return true;
        } catch (Exception e) {
            log.warn("Ping failed, serverUrl: " + serverUrl + ", error: " + e.getMessage());
            log.debug(e);
            return false;
        }
    }
}
